/*******************************************************************************
 * Copyright(c) 2023 Levetop Semiconductor Co.,Led. All rights reserved.
 * @file     keyBoard.h
 * @author   UartTFT Application Team
 * @version  V0.0.1
 * @date     2023-01-11
 * @brief    This file provides UartTFT Application display function
 ********************************************************************************/

#ifndef KEYBOARD_EN_H_
#define KEYBOARD_EN_H_
#include "type.h"
#include "module_select.h"

/*data input*/
typedef struct
{
	uint16_t Code; // Function code
	uint8_t len;   // lenght
	uint16_t Xs;   // Upper left corner coordinate
	uint16_t Ys;
	uint16_t Xe; // Lower right corner coordinate
	uint16_t Ye;
	uint16_t p_add; // variable pointer
	uint8_t p_tpye; // variable type
	uint8_t I_num;	// Bit of integer
	uint8_t D_num;	// Bit of decimal
	uint16_t kb_x;	// Keyboard display position
	uint16_t kb_y;
	uint16_t dp_x; // data display position
	uint16_t dp_y;
	uint8_t zk_id;
	uint8_t zk_w;
	uint8_t zk_h;
	uint8_t cursor_color;
	uint16_t kb_id;
	uint8_t Limite_EN; // 0xFF:Enable input range limit
	int32_t V_min;	   // lower limit
	int32_t V_max;	   // upper limit
	uint8_t Alig;	   // left justifying or right  justifying of data
	uint32_t fcolor;

} Dio_Info;
extern Dio_Info gDio_Info[DIO_SIZE];
extern uint8_t Dio_count;
extern uint8_t Dio_num;
extern uint8_t Dio_flag;
/***********/

extern void data_input(void);
extern void input_display(void);
extern uint8_t buff_to_var(uint8_t *buff);


/*********ASCII keyboard*****/
/*keyboard touch*/
typedef struct
{
	uint16_t Code; // Function code
	uint8_t len;   // lenght
	uint16_t Xs;   // Upper left corner coordinate
	uint16_t Ys;
	uint16_t Xe; // Lower right corner coordinate
	uint16_t Ye;
	uint16_t Keyvalue; // Key value
	uint16_t press_id; // variable type

} Kb_Info;
extern Kb_Info gKb_Info[];
extern uint8_t Kb_count;
extern uint8_t Kb_num;
extern uint8_t Kb_flag;
extern uint8_t DioKb_flag;
extern uint8_t dot_flag;
extern uint8_t i_len;
extern uint8_t d_len;
extern uint16_t input_len;
extern uint8_t neg_flag;
extern uint16_t input_w;
extern uint8_t cur_w;
extern uint16_t cur_x;
extern uint16_t cur_y;
extern uint16_t Cusor_time;
extern uint8_t Cusor_sw;
/***********/


typedef struct
{
	uint16_t Code; // Function code
	uint8_t len;   // lenght
	uint16_t Xs;   // Upper left corner coordinate
	uint16_t Ys;
	uint16_t Xe; // Lower right corner coordinate
	uint16_t Ye;
	uint16_t p_add;		  // variable pointer
	uint16_t p_len;		  // variable lenght
	uint8_t scan_mode;	  // entry mode
	uint8_t zk_id;		  // font id
	uint8_t zk_w;		  // width of font
	uint8_t zk_h;		  // high of font
	uint8_t cursor_color; // color of cursor
	uint32_t fcolor;
	uint16_t dp_x; // Text display position
	uint16_t dp_y;
	uint16_t kb_id;
	uint16_t kb_x; // Keyboard display position
	uint16_t kb_y;
	uint8_t input_mode;
	uint32_t zk_addr;
} Aio_Info;

extern Aio_Info gAio_Info[AIO_SIZE];
extern uint8_t Aio_count;
extern uint8_t Aio_num;
extern uint8_t Aio_flag;
extern uint8_t AioKb_flag;
extern uint8_t CapsLock; // Caps lock

/**********GBK keyboard*****/
typedef struct
{
	uint16_t Code; // Function code
	uint8_t len;   // lenght
	uint16_t Xs;   // Upper left corner coordinate
	uint16_t Ys;
	uint16_t Xe; // Lower right corner coordinate
	uint16_t Ye;
	uint16_t p_add;		  // variable pointer
	uint16_t p_len;		  // variable lenght
	uint8_t scan_mode;	  // entry mode
	uint8_t zk_id;		  // font id
	uint8_t zk_w;		  // width of font
	uint8_t zk_h;		  // high of font
	uint8_t cursor_color; // color of cursor
	uint32_t fcolor;
	uint16_t dp_x; // Text display position
	uint16_t dp_y;
	uint32_t pycolor;
	uint8_t py_zk;
	uint8_t py_w;
	uint8_t py_h;
	uint16_t py_x; // PY display position
	uint16_t py_y;
	uint16_t cn_x;
	uint16_t cn_y;
	uint8_t spacing; // Chinese character display spacing
	uint16_t kb_id;
	uint16_t kb_x; // Keyboard display position
	uint16_t kb_y;
	uint8_t input_mode;
	uint32_t zk_addr;
	uint32_t py_addr;
} GBKio_Info;
extern GBKio_Info gGBKio_Info[];
extern uint8_t GBKio_count;
extern uint8_t GBKio_num;
extern uint8_t GBKio_flag;
extern uint8_t GBKioKb_flag;
extern uint8_t GBK_PY_length; // PY lenght
extern uint8_t GBK_CN_EN;	  // Chinese and English input method enable
extern uint8_t GBK_PY_buff[];
extern uint16_t GBK_PY_num;
extern uint8_t GBK_len;
extern uint32_t GBK_PY_addr;
extern uint8_t GBK_linenum;
extern uint16_t GBK_py_w;
extern uint16_t GBK_cn_w;
/********************/

extern void Ascii_input(void);
extern void GBK_input(void);
#endif /* KEYBOARD_EN_H_ */
